--include the Stargate Base tool
include("weapons/gmod_tool/stargate_base_tool.lua");
--Our Current Category ... im going to move this to the config file soon.
TOOL.Category="Janus's Lantis Tech";
TOOL.Name="#ZPM Recahrger";

-- The default model for the GhostPreview
TOOL.ClientConVar["model"] = "models/mak/gen/gen.mdl";
TOOL.ClientConVar["autoweld"] = 1;

-- Information about the SENT to spawn
TOOL.Entity.Class = "zpm_recharger";
TOOL.Entity.Limit = 1;

-- Add the topic texts
TOOL.Topic["name"] = "Stargate Energy Device Recharger";
TOOL.Topic["desc"] = "Recharges Zpm's and Naquadah devices";
TOOL.Topic[0] = "Left click, to spawn the recahrger";

--Language
TOOL.Language["Undone"] = "ZPM Recharger removed";
TOOL.Language["Cleanup"] = "ZPM Recahrger's";
TOOL.Language["Cleaned"] = "Removed all ZPM Recharger's";
TOOL.Language["SBoxLimit"] = "Too many ZPM Recahrger's";


--################# LeftClick Toolaction @aVoN
function TOOL:LeftClick(trace)
	if(trace.Entity and trace.Entity:IsPlayer()) then return false end;
	if(trace.Entity and trace.Entity:GetClass() == self.Entity.Class) then return false end;
	if(CLIENT) then return true end;
	if(not self:CheckLimit()) then return false end;
	local p = self:GetOwner();
	--######## Spawn SENT
		local e = self:SpawnSENT(p,trace);
		local c = self:Weld(e,t.Entity,util.tobool(self:GetClientNumber("autoweld")));
		--######## Cleanup and undo register
		self:AddUndo(p,e,c);
		self:AddCleanup(p,c,e);
		return true;
end

--################# Controlpanel @aVoN
function TOOL:ControlsPanel(Panel)
	Panel:CheckBox("Autoweld","zpm_recharger_autoweld");
	Panel:Help("This spawns the ZPM Recahrger device. It can recahrge ZPM's, ZPM Mk2's and naquadah bottles at the moment.");
end

--################# Register Stargate hooks. Needs to be called after all functions are loaded!
TOOL:Register();
